package com.GZX;

import com.publicClass.CRUD;
import com.publicClass.User;

import static com.GZX.Status.*;
import static com.util.Vessel.*;

//宿舍管理
public class Dormitory {
    //学生id
    private long sId;

    //宿舍编号
    private int dId;

    //宿舍位置
    private String dLocation;

    //宿舍状态
    private Status dStatus;

    //公告
    private String dNotice;

    public Dormitory() {
    }

    public Dormitory(long sId, int dId, String dLocation, Status dStatus, String dNotice) {
        this.sId = sId;
        this.dId = dId;
        this.dLocation = dLocation;
        this.dStatus = dStatus;
        this.dNotice = dNotice;
    }

    public long getsId() {
        return sId;
    }

    public void setsId(long sId) {
        this.sId = sId;
    }

    public int getdId() {
        return dId;
    }

    public void setdId(int dId) {
        this.dId = dId;
    }

    public String getdLocation() {
        return dLocation;
    }

    public void setdLocation(String dLocation) {
        this.dLocation = dLocation;
    }

    public Status getdStatus() {
        return dStatus;
    }

    public void setdStatus(Status dStatus) {
        this.dStatus = dStatus;
    }

    public String getdNotice() {
        return dNotice;
    }

    public void setdNotice(String dNotice) {
        this.dNotice = dNotice;
    }

    public String toString(){
        return "\t\t\t\t\t" + getdId() + "\t\t\t\t" + getdLocation() + "\t\t\t" + getdStatus() + "\t\t\t" + getdNotice();
    }

    public String toString1(){
        return "\t\t\t\t\t" + getdId() + "\t\t\t\t" + getdLocation() + "\t\t\t" + getdStatus() + "\t\t\t" + getdNotice();
    }
    public String toString2(){
        return "\t\t\t\t\t" + getdId() + "\t\t\t\t" + getdLocation() + "\t\t\t" + getdStatus() + "\t\t\t" + getdNotice();
    }


    public static CRUD<Dormitory> dormitoryCRUD = new CRUD<>();
    //导入宿舍信息
    public static void channel(){

    }

    //查看宿舍列表
    public static void printList(){
        System.out.println("宿舍列表：" + "\t\t\t" + "宿舍编号" + "\t\t\t" + "宿舍位置"  + "\t\t\t" + "宿舍状态" + "\t\t\t" + "宿舍公告");
        for(Dormitory dormitory : dormitories){
            System.out.println(dormitory.toString());
        }
    }

    //宿舍详情（根据宿舍编号查看宿舍详情）
    public static void infoDormitory(){
        System.out.println("请输入宿舍号：");
        int dId = scanner.nextInt();
        System.out.println("宿舍列表：" + "\t\t\t" + "宿舍编号" + "\t\t\t" + "宿舍位置"  + "\t\t\t" + "宿舍状态" + "\t\t\t" + "宿舍公告");
        for (Dormitory dormitory : dormitories) {
            if (dormitory.getdId() == dId) {
                System.out.println(dormitory.toString());
            }
        }
    }

    //根据宿舍号查询宿舍成员
    public static void member(){
        System.out.println("请输入宿舍号：");
        int dId = scanner.nextInt();
        System.out.println("账号\t\t\t" + "\t姓名\t\t\t" + "密码\t\t\t" + "性别\t\t\t" + "年龄\t\t\t\t" + "联系方式\t\t\t" + "专业\t\t\t" + "\t身份角色\t\t\t" + "所在班级\t\t\t" + "宿舍编号\t\t" + "年级\t\t\t");
        for(User user : users){
            if (user.getDormitoryId() == dId){
                System.out.println(user.toStringL1());
            }
        }
    }

    //我的宿舍
    public static void myDormitory(long Id){
        System.out.println("宿舍列表:" + "\t\t\t" + "宿舍位置" + "\t\t\t" + "宿舍编号" + "\t\t\t" + "宿舍状态" + "\t\t\t" + "宿舍维修信息");
        for(Dormitory dormitory : dormitories){
            if (dormitory.getsId() == Id){
                System.out.println(dormitory.toString());
            }
        }
    }

    //宿舍报修申请
    public static void apply(long Id){
        for (Dormitory dormitory : dormitories) {
            if (dormitory.getsId() == Id) {
                dormitory.setdStatus(维修申请);
                System.out.println("保修审批中。。。");
            }
        }
    }

    //宿舍保修审核
    public static int approve(){
        System.out.println("请输入宿舍号：");
        int dId = scanner.nextInt();
        for (Dormitory dormitory : dormitories) {
            if (dormitory.getdId() == dId) {
                System.out.println("请输入审核详情");
                System.out.println("请选择宿舍维修详情:1:批准申请    2：待定。。。。");
                int input = scanner.nextInt();
                switch (input){
                    case 1:
                        dormitory.setdStatus(申请批准);
                        break;
                    case 2:
                        dormitory.setdStatus(申请等待);
                        break;
                }
            }
        }
        return dId;
    }

    //维修宿舍中
    public static void service(){
        System.out.println("请输入需要维修的宿舍号：");
        int dId = scanner.nextInt();
        for (Dormitory dormitory : dormitories) {
            if (dormitory.getdId() == dId) {
                System.out.println("请选择宿舍维修详情:1:维修完成  2：维修中。。。");
                int input = scanner.nextInt();
                switch (input){
                    case 1:
                        dormitory.setdStatus(正常状态);
                        break;
                    case 2:
                        dormitory.setdStatus(维修状态);
                        break;
                }

            }
        }
    }

    //宿舍公告发布
    public static void publish(){
        for (Dormitory dormitory : dormitories){
            System.out.println("请输入公告内容：");
            dormitory.dNotice = scanner.next();
        }
    }

    //查看宿舍公告
    public static void check(){
        for (Dormitory dormitory : dormitories){
            if (dormitory.getdNotice() != null){
                System.out.println(dormitory.getdNotice());
            }
        }
    }

    public static void main(String[] args) {
//        printList();//查看宿舍列表
//        infoDormitory();//宿舍详情（根据宿舍编号查看宿舍详情）
        myDormitory(99999);//查看学生个人宿舍
//        apply(10000001);  //申请维修个人宿舍
//        member();

        approve();

        infoDormitory();//宿舍详情（根据宿舍编号查看宿舍详情）
    }
}
